﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;
using System.Text;
using HKEA.CMS.Core.IDAL.App;
using HKEA.CMS.Core.IDAL.Tbl;
using HKEA.CMS.Core.Models;
using HKEA.CMS.Core.DALFactory;
using HKEA.CMS.Core.Utility;

namespace HKEA.CMS.Core.BLL.App
{
    public class app_tblMediaRoomBLL
    {
         private Iapp_tblMediaRoom IDAL;
         HKEA_CMSEntities model;

        public app_tblMediaRoomBLL()
        {
            IDAL = DataAccess.CreateIapp_tblMediaRoom();
        }
        public static app_tblMediaRoomBLL GetInstance()
        {
            return new app_tblMediaRoomBLL();
        }

        public app_tblMediaRoom GetEntity(int uid)
        {
            try
            {
                return IDAL.GetEntity(uid);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public app_tblMediaRoom GetEntity(app_tblMediaRoom ent)
        {
            try
            {
                return IDAL.GetEntity(ent);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public app_tblMediaRoom GetLastEntity()
        {
            try
            {
                return IDAL.GetLastEntity();
            }
            catch (Exception)
            {
                throw;
            }
        }
        

        /// <summary>
        /// 插入一条记录，返回当前记录的UID ； 并非影响行数
        /// </summary>
        /// <param name="ent"></param>
        /// <returns></returns>
        public int InsertENT(app_tblMediaRoom ent)
        {
            int ret=0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.InsertENT(ent); 
                }
                catch (Exception er)
                {
                    throw;
                }
            }
            return ret;
        }

        public List<app_tblMediaRoom> GetListByENT(app_tblMediaRoom ent)
        {
            var ret = new List<app_tblMediaRoom>();
            if (ent != null)
            {
                try
                {
                    ret = IDAL.GetListByENT(ent);
                }
                catch (Exception er)
                { throw; }
            }
            return ret;
        }

        public List<MediaRoomList> GetList(app_tblMediaRoom ent,bool IsAddDeletedForSelect)
        {
            List<MediaRoomList> list = new List<MediaRoomList>();
            if (ent != null)
            {
                try { list = IDAL.GetList(ent, IsAddDeletedForSelect); }
                catch(Exception er){throw;}
            }
            return list;
        }
        public int UpdateENT(app_tblMediaRoom ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.UpdateENT(ent);
                }
                catch (Exception er)
                { throw; }
            }
            return ret;
        }
        public int DeleteENT(app_tblMediaRoom ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.DeleteENT(ent);
                }
                catch (Exception er)
                { throw; }
            }
            return ret;
        }
    }
}
